From 1e15d0af59a2a1db9d974e1a47b98ad3d6d08431 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 1 Oct 2016 13:53:42 +0300 Subject: [PATCH] Store CargoError inside the ProcessError --- src/cargo/util/errors.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cargo/util/errors.rs b/src/cargo/util/errors.rs index 39e22cbe5..0f1bfe9ef 100644 --- a/src/cargo/util/errors.rs +++ b/src/cargo/util/errors.rs @@ -23,6 +23,7 @@ pub type CargoResult = Result>; pub trait CargoError: Error + Send + 'static { fn is_human(&self) -> bool { false } fn cargo_cause(&self) -> Option<&CargoError>{ None } + fn as_error(&self) -> &Error where Self: Sized { self as &Error } } impl Error for Box { @@ -110,13 +111,13 @@ pub struct ProcessError { pub desc: String, pub exit: Option, pub output: Option, - cause: Option>, + cause: Option>, } impl Error for ProcessError { fn description(&self) -> &str { &self.desc } fn cause(&self) -> Option<&Error> { - self.cause.as_ref().map(|e| &**e as &Error) + self.cause.as_ref().map(|e| e.as_error()) } } @@ -375,7 +376,7 @@ impl CargoError for str::ParseBoolError {} // Construction helpers pub fn process_error(msg: &str, - cause: Option>, + cause: Option>, status: Option<&ExitStatus>, output: Option<&Output>) -> ProcessError { -- 2.30.2